package com.ysd.crm.controller;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ysd.crm.entity.NetFollows;
import com.ysd.crm.entity.seach.NetFollowsSeach;
import com.ysd.crm.service.NetFollowsService;
import com.ysd.crm.utils.LayResult;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RequestMapping("/Net")
@RestController
@Api
public class NetFollowsController {
	@Autowired
	private NetFollowsService nService;
	@ApiOperation("跟踪-gmw")
	@PostMapping("addNet")
	public Object AddNet(NetFollows n) {
		n.setCreateTime(new Date());
		int nf=nService.insertNetFollows(n);		
		if(nf>0) {
			return LayResult.toClient("0","跟踪成功");
		}
		return LayResult.toClient("1","跟踪失败");
	}
	@ApiOperation("日志-gmw")
	@GetMapping("getNet")
	public Object getNet(NetFollowsSeach n) {
		n.setPage((n.getPage()-1)*n.getLimit());
		List<NetFollows> net= nService.findNetFollows(n);
		int count=nService.findCount(n);
		if(net!=null) {
			return LayResult.toClient("0", "查询成功",count,net);
		}else {
			return LayResult.toClient("1", "查询失败");
		}
	}
}
